package org.opens.guava.utilites.eventBus.events;

import com.google.common.eventbus.EventBus;
import org.junit.Test;
import org.opens.guava.utilites.eventBus.listeners.ConcreteListener;
import org.opens.guava.utilites.eventBus.listeners.SimpleListener;

public class InheritEventBusExample {

    /**
     * 功能:
     *      测试监听器继承会发生什么.
     * 输出:
     *      12:36:22.232 [main] INFO org.opens.guava.utilites.eventBus.listeners.SimpleListener - the event: [simple event] handle by ConcreteListener.doAction1
     *      12:36:22.237 [main] INFO org.opens.guava.utilites.eventBus.listeners.SimpleListener - the event: [simple event] handle by ConcreteListener.doAction
     *      12:36:22.237 [main] INFO org.opens.guava.utilites.eventBus.listeners.SimpleListener - the event: [simple event] handle by ConcreteListener.doAction2
     * 说明:
     *      1. 这个输出说明了两点:
     *          - 继承的方法已经属于当前子类了, 因为在方法中打印的getClass().getSimpleName()是当前子类的名称.
     *          - 继承的方法同样会被相同的参数类型触发.
     */
    @Test
    public void test1() {
        final EventBus eventBus = new EventBus();
        eventBus.register(new ConcreteListener());
        eventBus.post("simple event");
        eventBus.post(999);
    }

}
